﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CommonMasterTop.ascx.cs" Inherits="ETD.WebManagement.Admin.Controls.CommonMasterTop" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<% string mwsAssetsUrl = "/Assets/MwsAssets/"; %>
<script src="<%=ResolveClientUrl(mwsAssetsUrl+"js/libs/jquery-1.8.3.min.js")%>"></script>
<telerik:RadScriptManager runat="server" EnableCdn="false" ID="RadScriptManagerDefault" AsyncPostBackTimeout="600">
    <Scripts>
        <%--                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />--%>
    </Scripts>
</telerik:RadScriptManager>
<telerik:RadStyleSheetManager runat="server" ID="AdminRadStyleSheet" />
<style>
    .RadNotification .rnContentWrapper {
        margin-top: 15px !important;
    }

    .RadNotification .rnContent {
        padding-top: 16px !important;
    }
</style>
<%--<telerik:radformdecorator runat="server" id="AdminRadFormDecorator"  />--%>
<telerik:RadWindowManager runat="server" ID="RadWindowManagerDefault" culture="zh-CN">
</telerik:RadWindowManager>
<telerik:RadToolTip ID="RadToolTipDefault" runat="server" Height="100px" Width="150px"
    IsClientID="true"
    OnClientHide="OnRadToolTipDefaultHide" Position="Center"
    RelativeTo="Element" Text="test">
</telerik:RadToolTip>
<telerik:RadNotification ID="RadNotificationDefault" runat="server" EnableRoundedCorners="false" Position="Center"
    EnableShadow="true" Text="Sample content" Title="Sample title" Width="300" Height="140" AutoCloseDelay="2000">
</telerik:RadNotification>

<asp:Panel ID="MessageContainer" runat="server" Height="0" Width="0"></asp:Panel>


<telerik:RadWindow runat="server" ID="DefaultWindow" VisibleStatusbar="true"
    ShowContentDuringLoad="false"
    Width="600" Height="600" EnableShadow="true" Title="用户权限" Modal="true">
</telerik:RadWindow>


<telerik:RadCodeBlock runat="server" ID="codeBlock">
    <script type="text/javascript">
        Telerik.Web.UI.RadWindowUtils.Localization = {
            "OK": "确定",
            "Cancel": "取消",
        };
        $telerik.$(document).ready(function () {

        });
        function inIframe() {
            if (!self.frameElement || self.frameElement.tagName != "IFRAME") {
                // 页面不在iframe中时处理 
                return false;
            } else {
                return true;
            }
        }
        var win = window;
        if (inIframe()) {
            win = window.parent;
        }
        var iconCancelUrl = "<%=ResolveClientUrl("/Assets/MwsAssets/css/icons/icol32/cancel.png")%>";
        var iconAcceptUrl = "<%=ResolveClientUrl("/Assets/MwsAssets/css/icons/icol32/accept.png")%>";
        var iconInformationUrl = "<%=ResolveClientUrl("/Assets/MwsAssets/css/icons/icol32/information.png")%>";
        var AlertObjectIconUrl = {
            Cancel: iconCancelUrl,
            Ok: iconAcceptUrl,
            Info: iconInformationUrl
        };
        var ConfirmObjectIconUrl = {
            Cancel: iconCancelUrl,
            Ok: iconAcceptUrl,
            Info: iconInformationUrl
        };

        var AlertObject = {
            openOkAlert: function (para) {
                win.radalert(para.title, para.width, para.height, para.text, para.callBack, para.iconUrl);
            },
            alertCallBackFn: function (arg) {
                alert("call back,please customer you selef call back");
            }
        };

        function AlertParamter() {
        };
        AlertParamter.prototype.title = "信息";
        AlertParamter.prototype.callBack = AlertObject.alertCallBackFn;
        AlertParamter.prototype.width = 300;
        AlertParamter.prototype.height = 140;
        AlertParamter.prototype.text = "信息";
        AlertParamter.prototype.iconUrl = AlertObjectIconUrl.Info;



        var ConfirmObject = {
            openOkAlert: function (para) {
                //radalert(para.title, para.width, para.height, para.text, para.callBack, para.iconUrl);
                win.radconfirm(para.text, para.callBack, para.width, para.height
                    , null, para.title, para.iconUrl);
            },
            confirmCallBackFn: function (arg) {
                //这里请设置自己的 回调函数
                alert("call back,please customer you selef call back");
            }
        };
        function ConfirmParamter(title, text, callBack) {
            ConfirmParamter.prototype.title = title;
            ConfirmParamter.prototype.text = text;
            ConfirmParamter.prototype.callBack = callBack;
        };
        ConfirmParamter.prototype.title = "信息";
        ConfirmParamter.prototype.callBack = ConfirmObject.confirmCallBackFn;
        ConfirmParamter.prototype.width = 300;
        ConfirmParamter.prototype.height = 140;
        ConfirmParamter.prototype.text = "信息";
        ConfirmParamter.prototype.iconUrl = ConfirmObjectIconUrl.Info;

        function OnRadToolTipDefaultHide(sender, eventArgs) {
            alert("hit2");
        }
        RadToolTipObject = {
            show: function () {
                var tooltip = $find("<%= RadToolTipDefault.ClientID %>");
                tooltip.show();
            },
            hide: function () {
                var tooltip = $find("<%= RadToolTipDefault.ClientID %>");
                tooltip.hide();
            }
        };

        //AlertObject.showFinishedAlert();
        //如果界面有Window弹出框（嵌套其他页面的IframeWindow），那么点击Cacel按钮的时候，要调用一下，这样能够关闭对话框
        function onCloseRadWindowManagerDefault(sender, args) {
            ConfirmObject.openOkAlert(new ConfirmParamter("确认？", "确认要取消？", onCloseRadWindowManagerDefaultProcessing))
            //args.set_cancel(true);
        }
        function onCloseRadWindowManagerDefaultEx(sender, args) {
            onCloseRadWindowManagerDefaultProcessing(true);
        }
        //如果界面有Window弹出框（嵌套其他页面的IframeWindow），那么点击Cacel按钮的时候，要调用一下，这样能够关闭对话框
        //这个是 当确认是否关闭之后的 动作，如果确认就关闭，没确认就不关闭
        function onCloseRadWindowManagerDefaultProcessing(arg) {
            if (arg) {
                parent.DefaultWindow.closeWindow();
                if (typeof (parent.window.refreshPageWithState) != "undefined")
                    parent.window.refreshPageWithState();
            }
        }
        function onCloseRadWindowManagerDefaultDirect() {
            setTimeout(function () {
                parent.DefaultWindow.closeWindow();
                if (typeof (parent.window.refreshPageWithState) != "undefined")
                    parent.window.refreshPageWithState();
            }, "2000");
        }
        function RadWindowManagerDefaultCallBackFn(arg) {
            // radalert("<strong>radalert</strong> returned the following result: <h3 style='color: #ff0000;'>" + arg + "</h3>", 350, 250, "Result");
            parent.DefaultWindow.closeWindow();
        }
        //刷新父窗口
        function RefreshParentPage() {
            parent.window.location.replace(parent.window.location.href);
        }
        //刷新当前页面
        function RefreshPage() {
            window.location.replace(window.location.href);
        }
        //跳转页面
        function RedirectPage(url) {
            window.location.href = url;
        }
        //默认弹出Window，可以嵌套任何Page
        var DefaultWindow = {
            window: null,
            init: function () {
            },
            openWindow: function (title, url, width, height) {
                if (typeof (MainMenu) != "undefined")
                    MainMenu.putDown();
                DefaultWindow.window = $find("<%= DefaultWindow.ClientID %>");
                DefaultWindow.window.set_title(title);
                DefaultWindow.window.setUrl(url);
                DefaultWindow.window.set_width(width);
                DefaultWindow.window.set_height(height);
                DefaultWindow.window.show();
            },
            closeWindow: function () {
                DefaultWindow.window.close();
            }
                    , maximize: function () {
                        DefaultWindow.window.maximize();
                    }
        };

        //点击Cancel按钮时候的 确认对话框
        function onCancelButtonConfirm(onCancelCallBack) {
            ConfirmObject.openOkAlert(new ConfirmParamter("确认？", "确认要取消？", onCancelCallBack))
            //args.set_cancel(true);
        }
        //删除确认对话框
        function onDeleteRadconfirm(text, radconfirmCallBack) {

            win.radconfirm(text, radconfirmCallBack, 300, 140, null, '确定删除？', iconCancelUrl);
        }
        //onDefaultRadconfirm
        function onDefaultRadconfirm(text, radconfirmCallBack) {
            win.radconfirm(text, radconfirmCallBack, 300, 140, null, '提示信息', iconCancelUrl);
        }
        function showNotification(info, title, second) {
            var notification = $find("<%=RadNotificationDefault.ClientID %>");
            //这个提醒的 使用 必须是 带有RadAjaxLoadingPanel的 Ajax页面才行，否则会报错 
            notification.set_text(info);
            if (title) {
                notification.set_title(title);
            } else {
                notification.set_title("提示信息");
            }
            if (second) {
                notification.set_autoCloseDelay(second);
            } else {
                notification.set_autoCloseDelay(2000);
            }

            notification.show();
        }
        $(document).ready(function () {

            //if ($("#form1").length > 0) {
            //    if ($(".formTable").length > 0) {
            //        //var height = $("#form1").height().substring(0, $("#form1").height().indexOf("px"));
            //        //var h = intParse(height) - 20;
            //        var height = $("#form1").height();
            //        $(".RadAjaxPanelDefault").height(height - 30);
            //    }
            //}
        });

        //页面状态
        var PageStateObject = {
            _isClientRefresh: false,
            getIsClientRefresh: function () {
                var tempResult = PageStateObject._isClientRefresh;
                PageStateObject._isClientRefresh = false;
                return tempResult;
            },
            setIsClientRefresh: function (val) {
                PageStateObject._isClientRefresh = val;
            }
        };

        function onRowMouseOver(sender, eventArgs) {
            var dataItem = eventArgs.get_gridDataItem();
            if (dataItem) {
                dataItem.addCssClass("grid-over-row");

                var curRow = $(dataItem.get_element());

                if (curRow.hasClass("rgAltRow"))
                    curRow.css({ "background-color": "" });
            }
        }

        function onRowMouseOut(sender, eventArgs) {

            var dataItem = eventArgs.get_gridDataItem();
            if (dataItem) {
                dataItem.removeCssClass("grid-over-row");

                var curRow = $(dataItem.get_element());

                if (curRow.hasClass("rgAltRow"))
                    curRow.css({ "background-color": "#f2f2f2" });
            }
        }
    </script>
</telerik:RadCodeBlock>
